home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / ABUSESRC.ZIP / AbuseSrc / macabuse / inc / fakelib.hpp < prev    next >
C/C++ Source or Header  |  1997-05-20  |  1KB  |  43 lines

  1. #ifndef __FAKELIB_HPP_
  2. #define __FAKELIB_HPP_
  3.  
  4. #define jmalloc(x,y) malloc(x)
  5. #define jrealloc(x,y,z) realloc(x,y)
  6. #define jfree(x) free(x)
  7. #define uchar  unsigned char
  8. #define schar  signed char
  9. #define sshort signed short
  10.  
  11. #ifdef __sgi
  12. #include <sys/bsd_types.h>
  13. #else
  14. #define ulong  unsigned long
  15. #define ushort unsigned short
  16. #endif
  17.  
  18. class bFILE
  19. {
  20.   public :
  21.   FILE *fp;
  22.   bFILE(FILE *FP) { fp=FP; }
  23.   bFILE(char *fn, char *mode) { fp=fopen(fn,mode); }
  24.   long file_size() { long cur=ftell(fp),ret; fseek(fp,0,2); ret=ftell(fp); 
  25.              fseek(fp,cur,0); return ret; }
  26.   int read(void *buf, int count) { return fread(buf,count,1,fp); }
  27.   int write(void *buf, int count) { return fwrite(buf,count,1,fp); }
  28.   int write_byte(uchar x) { return fputc(x,fp); }
  29.   int open_failure() { return fp==NULL; }
  30.   ~bFILE() { if (fp) fclose(fp); }
  31. } ;
  32.  
  33. #define jFILE bFILE
  34.  
  35. bFILE *open_file(char *name, char *perm) { return new bFILE(fopen(name,perm)); }
  36. #define dprintf printf
  37. void dgets(char *s, int x)
  38. { fgets(s,x,stdin);
  39.   if (strlen(s)>0) s[strlen(s)-1]=0;
  40. }
  41.  
  42. #endif
  43.